<?php
declare(strict_types=1);

namespace app\admin\validate;

use think\Validate;

class Login extends Validate
{
    // 验证规则
    protected $rule = [
        'username' => 'require|max:20',
        'password' => 'min:6|max:80',
        'password_confirm'  => 'confirm:password',
        'phone'    => 'require|mobile',
        'email'    => 'require|email',
    ];

    // 错误提示
    protected $message = [
        'username.require' => '用户名必须填写',
        'username.max'     => '用户名最多20个字符',
        'password.min'     => '密码不少于6个字符',
        'password.max'     => '密码不超过80个字符',
        'password_confirm.confirm' => '两次密码不一致',
        'phone.require'    => '手机号必须填写',
        'phone.mobile'     => '请输入正确手机号',
        'email.require'    => '邮箱必须填写',
        'email.email'      => '请输入正确邮箱',
    ];

    // 验证场景
    protected $scene = [
        'login'  => ['username', 'password'],
        'editSelf'   => ['username', 'password', 'password_confirm', 'email', 'phone'],
    ];
}